import request from '@/utils/request'

export default {
    getRoleList(searchModel) {
        return request({
            url: "/role/list",
            method: "get",
            params: searchModel
        })
    },
    addRole(role) {
        return request({
            url: "/role/addrole",
            method: "post",
            data: role
        })
    },
    saveRole(role) {
        if (role.roleId == null || role.roleId == undefined) {
            return this.addRole(role)
        }
        return this.updateRole(role)
    },
    updateRole(role) {
        return request({
            url: '/role/updaterole',
            method: "put",
            data: role
        })
    },
    getRoleById(id) {
        return request({
            url: `/role/getrole/${id}`,
            method: "get",
        })
    },
    deleteRoleById(id) {
        return request({
            url: `/role/deleterole/${id}`,
            method: "delete",
        })
    },
    getAllRoleList() {
        return request({
            url: "/role/all",
            method: "get",
        })
    },
}